n = 50
while n != 0:
    if n % 3 == 0:
        print(n,end=' ')
    elif int(n / 10) == 3:
        print(n,end=' ')
    elif n - int(n / 10)*10 == 3:
        print(n,end=' ')
    n-=1